<?php

$foo=$_GET["reportid"];
$toperson=$_GET["toperson"];
$username=getenv('WEBAUTH_USER');

include("mysql_conn.php");

$result=mysql_query("select fullname from users where username='$username'");
while($row=mysql_fetch_array($result))
{
 $fullname=$row['fullname'];
}

$headers="From: $username@stanford.edu"."\r\n"."MIME-Version: 1.0"."\r\n"."Content-type:text/html;charset=iso-8859-1" . "\r\n";

$result=mysql_query("select report_data from status_reports where reportid=$foo");

while ($row=mysql_fetch_array($result))
{
	$message = "$row[0]";
}

 mail("$toperson","Status report from $fullname",$message,$headers);

mysql_close($con);

echo "<html><head><meta http-equiv='refresh' content='0;url=myreports.php'><link rel='stylesheet' type='text/css' href='style.css'></head><body>
Status report emailed successfully.<p>
<a href='myreports.php?username=$WEBAUTH_USER'>Return to My Reports</a>
</body></html>";

?>
